]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
UnlockDialog: allow typing before the first question from PAM
authorGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 13 Aug 2012 10:49:04 +0000 (12:49 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 14 Sep 2012 16:40:19 +0000 (18:40 +0200)
If the user starts typing right away, assume that the entry is
for a password and don't clear it when the secret request actually
comes. Then, if the user completes typing, we also stash the answer
and send it to GDM right away on the first PAM prompt.

https://bugzilla.gnome.org/show_bug.cgi?id=681576

js/ui/unlockDialog.js

index 6fcbda74731e0f8f17d92a19752ace65c3772222..1ceb35a72cc0af5097a61cf30e80e26de7ed03b8 100644 (file)
@@ -91,6 +91,7 @@ const UnlockDialog = new Lang.Class({
         this._user = this._userManager.get_user(this._userName);
 
         this._failCounter = 0;
+        this._firstQuestion = true;
 
         this._greeterClient = new Gdm.Client();
         this._userVerifier = new GdmUtil.ShellUserVerifier(this._greeterClient, { reauthenticationOnly: true });
@@ -115,7 +116,8 @@ const UnlockDialog = new Lang.Class({
 
         this._promptEntry = new St.Entry({ style_class: 'login-dialog-prompt-entry',
                                            can_focus: true });
-        ShellEntry.addContextMenu(this._promptEntry);
+        this._promptEntry.clutter_text.set_password_char('\u25cf');
+        ShellEntry.addContextMenu(this._promptEntry, { isPassword: true });
         this.setInitialKeyFocus(this._promptEntry);
         this._promptEntry.clutter_text.connect('activate', Lang.bind(this, this._doUnlock));
 
@@ -140,7 +142,7 @@ const UnlockDialog = new Lang.Class({
                            default: true };
         this.setButtons([cancelButton, this._okButton]);
 
-        this._updateOkButton(false);
+        this._updateOkButton(true);
 
         let otherUserLabel = new St.Label({ text: _("Log in as another user"),
                                             style_class: 'login-dialog-not-listed-label' });
@@ -171,6 +173,7 @@ const UnlockDialog = new Lang.Class({
 
     _updateOkButton: function(sensitive) {
         this._okButton.button.reactive = sensitive;
+        this._okButton.button.can_focus = sensitive;
     },
 
     _showMessage: function(userVerifier, message, styleClass) {
@@ -180,9 +183,20 @@ const UnlockDialog = new Lang.Class({
     },
 
     _onAskQuestion: function(verifier, serviceName, question, passwordChar) {
+        if (this._firstQuestion && this._firstQuestionAnswer) {
+            this._userVerifier.answerQuery(serviceName, this._firstQuestionAnswer);
+            this._firstQuestionAnswer = null;
+            this._firstQuestion = false;
+            return;
+        }
+
         this._promptLabel.text = question;
 
-        this._promptEntry.text = '';
+        if (!this._firstQuestion)
+            this._promptEntry.text = '';
+        else
+            this._firstQuestion = false;
+
         this._promptEntry.clutter_text.set_password_char(passwordChar);
         this._promptEntry.menu.isPassword = passwordChar != '';
 
@@ -200,6 +214,15 @@ const UnlockDialog = new Lang.Class({
     },
 
     _doUnlock: function() {
+        if (this._firstQuestion) {
+            // we haven't received a query yet, so stash the answer
+            // and make ourself non-reactive
+            // the actual reply to GDM will be sent as soon as asked
+            this._firstQuestionAnswer = this._promptEntry.text;
+            this._updateOkButton(false);
+            return;
+        }
+
         if (!this._currentQuery)
             return;